import { defineConfig } from "vite";
import { resolve } from "path";
import vue from '@vitejs/plugin-vue'
// import path from "path";
// import copy from "rollup-plugin-copy";
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { crx } from '@crxjs/vite-plugin'
import manifest from './src/manifest.json'
import pkg from './package.json'

const isProd = process.env.NODE_ENV === "production"

manifest.name = isProd ? 'ac简历采集插件' : 'ac简历采集插件测试'

const crxOptions = {
  manifest: Object.assign(manifest, {
    version: pkg.version,
  })
}

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
    },
  },
  build: {
    outDir: isProd ? 'dist/build' : 'dist/dev',
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    crx(crxOptions)
  ]
});
